package com.aiti.lulian.entity.tree;

import com.aiti.lulian.entity.SysData;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 * 
 * @author ruoyi
 */
@Data
public class TreeSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private String baseId;

    /** 节点名称 */
    private String label;

    /** 节点顺序 */
    private Integer sort;

    /** 节点禁用 */
    private boolean disabled = false;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect(SysData sysData)
    {
        this.baseId = sysData.getBaseId();
        this.label = sysData.getBaseName();
        this.sort = sysData.getSort();
        this.children = sysData.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }
}
